Jenkins for Beginners - Spring Boot Development Guide
What is Jenkins?
Jenkins is an open-source automation server that enables Continuous Integration (CI) and Continuous Deployment (CD) for software development. It helps automate the building, testing, and deployment of Spring Boot applications.
Why Jenkins for Spring Boot?
- Automation: Automatically build and test your Spring Boot apps on code changes
- Integration: Works seamlessly with Maven/Gradle, Git, Docker
- Flexibility: Extensive plugin ecosystem
- Scalability: Can handle multiple projects and environments
- Free: Open-source with strong community support
Core Jenkins Concepts
Key Terminology
- Job/Project: A runnable task in Jenkins (e.g., build Spring Boot app)
- Build: Single execution of a job
- Workspace: Directory where Jenkins runs your job
- Node/Agent: Machine where Jenkins executes jobs
- Pipeline: Code-based job definition using Groovy
- Plugin: Extension that adds functionality to Jenkins
Jenkins Architecture
┌─────────────────┐
│ Jenkins Master │ ← Web UI, Job scheduling, Plugin management
├─────────────────┤
│ Jenkins Agents │ ← Execute jobs, can be on different machines
├─────────────────┤
│ Source Code │ ← Git repositories
├─────────────────┤
│ Artifacts │ ← JAR files, Docker images
└────────── ───────┘
Jenkins Installation
Local Installation (Development)
Option 1: Download WAR File
# Download Jenkins WAR
wget https://get.jenkins.io/war-stable/latest/jenkins.war
# Run Jenkins
java -jar jenkins.war --httpPort=8080
# Access: http://localhost:8080
Option 2: Docker (Recommended for beginners)
# Pull Jenkins image
docker pull jenkins/jenkins:lts
# Run Jenkins container
docker run -d \
--name jenkins \
-p 8080:8080 \
-p 50000:50000 \
-v jenkins_home:/var/jenkins_home \
jenkins/jenkins:lts
# Access: http://localhost:8080
Option 3: Docker Compose
# docker-compose.yml
version: '3.8'
services:
jenkins:
image: jenkins/jenkins:lts
container_name: jenkins
ports:
- "8080:8080"
- "50000:50000"
volumes:
- jenkins_home:/var/jenkins_home
- /var/run/docker.sock:/var/run/docker.sock
environment:
- JENKINS_OPTS="--httpPort=8080"
restart: unless-stopped
volumes:
jenkins_home:
Initial Setup Steps
- Access Jenkins: Navigate to
http://localhost:8080
- Unlock Jenkins: Use initial admin password from logs
- Install Plugins: Choose "Install suggested plugins"
- Create Admin User: Set up your admin account
- Configure Instance: Set Jenkins URL
Essential Plugins for Spring Boot Development
Must-Have Plugins
# Core plugins for Spring Boot
- Git Plugin # Git integration
- Maven Integration Plugin # Maven support
- Gradle Plugin # Gradle support
- JUnit Plugin # Test result visualization
- Jacoco Plugin # Code coverage
- SonarQube Scanner # Code quality
- Docker Plugin # Docker integration
- Blue Ocean # Modern UI
- Pipeline Plugin # Pipeline as Code
- Credentials Plugin # Secure credential storage
- SSH Agent Plugin # SSH key management